<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/27
 * Time: 16:14
 */

namespace app\api\controller\v1;


use app\api\model\Banner as BannerModel;
use app\api\validate\IDMustBePositiveInt;
use app\lib\Exception\BannerMissException;

class Banner
{
    public function getBanner($id)
    {
        //    验证id
        (new IDMustBePositiveInt())->toCheck();
        // return;
        //    model层返回数据
        // $banner = BannerModel::with('items')->find($id);
        $banner = BannerModel::getBannerByID($id);
        if (!$banner) {
            throw new BannerMissException();
        }
        return $banner;
    }

}